import axios from "axios";
// import { config } from "vue/types/umd";
const instance = axios.create({
    baseURL: '/api'
    // baseURL: "http://kumanxuan1.f3322.net:8881/cms"
});
// 请求拦截
instance.interceptors.request.use(config => {
    // console.log("请求拦截器-同一层加token");
    let mytoken = localStorage.getItem("x-auth-token")
    if (mytoken) {
        config.headers["x-auth-token"] = mytoken
    }
    return config
}, error => {
    return Promise.reject(error)
})
//响应拦截
instance.interceptors.response.use(function (response) {
    // console.log("响应拦截", response);
    if (response.data.code != 0 && response.data.code != 400 && response.data.code != 407) {
        alert(response.data.msg || response.data.message);
        return false;
    }
    return response.data
}, function (error) {
    return Promise.reject(error)
})
export default instance